<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Coder extends MX_Controller{

	public function __construct(){
		parent::__construct();
	}
	public function get_code_convert(){
		$sourceCode = $this->input->post('src');
		$response = array();
		$srcJson = json_decode($sourceCode, true);
		$len = count($srcJson);
		for ($i=0; $i < $len; $i++) {
			$line = trim($srcJson[$i]);
			if($line == '{' || $line == '}'){
				array_push($response, $line);
			}else if(!empty($line))
				array_push($response, modules::run('ctocplus/convert_c_to_cplus', $srcJson[$i]));
		}
		$code = '';
		foreach ($response as $item) {
			$code .= ' '.$item;
		}
		echo json_encode($response);
	}
}